import time
from selenium import webdriver
from selenium.webdriver.common.by import By

from ExcelData import *


class EnrollOperation:
    #输入账号密码重复密码，点击注册
    def enroll(self,driver,username,password,repassword):
        driver.find_element(By.XPATH,'//*[@id="username"]').send_keys(username)
        driver.find_element(By.XPATH,'//*[@id="password"]').send_keys(password)
        driver.find_element(By.XPATH, '//*[@id="repassword"]').send_keys(repassword)
        driver.find_element(By.XPATH, '/html/body/div/div/div/form/div[4]/button').click()
        time.sleep(1)

    def enroll1(self,driver,username,password):
        driver.find_element(By.XPATH,'//*[@id="username"]').send_keys(username)
        driver.find_element(By.XPATH,'//*[@id="password"]').send_keys(password)
        time.sleep(2)
        driver.find_element(By.XPATH, '/html/body/div/div/div/form/div[4]/button').click()
        time.sleep(2)
        driver.find_element(By.XPATH, '/html/body/div/div/div/form/div[4]/button').click()
        time.sleep(2)

    def enroll2(self,driver,username,password):
        driver.find_element(By.XPATH,'//*[@id="username"]').send_keys(username)
        time.sleep(2)
        driver.find_element(By.XPATH, '/html/body/div/div/div/form/div[4]/button').click()
        time.sleep(2)
    #断言重复密码为空
    def get_error_result(self, driver):
        result = driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[3]/span[1]").text
        return result

    # 断言密码为空
    def get_error_result1(self, driver):
        result = driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[2]/span[1]").text
        return result